home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 2000 October / Software of the Month - Ultimate Collection Shareware 277.iso / pc / PROGRAMS / UTILITY / WINLINUX / DATA1.CAB / programs_-_include / LINUX / HDREG.H < prev    next >
C/C++ Source or Header  |  1999-09-17  |  12KB  |  283 lines

  1. #ifndef _LINUX_HDREG_H
  2. #define _LINUX_HDREG_H
  3.  
  4. /*
  5.  * This file contains some defines for the AT-hd-controller.
  6.  * Various sources.  
  7.  */
  8.  
  9. #define HD_IRQ 14        /* the standard disk interrupt */
  10.  
  11. /* ide.c has its own port definitions in "ide.h" */
  12.  
  13. /* Hd controller regs. Ref: IBM AT Bios-listing */
  14. #define HD_DATA        0x1f0    /* _CTL when writing */
  15. #define HD_ERROR    0x1f1    /* see err-bits */
  16. #define HD_NSECTOR    0x1f2    /* nr of sectors to read/write */
  17. #define HD_SECTOR    0x1f3    /* starting sector */
  18. #define HD_LCYL        0x1f4    /* starting cylinder */
  19. #define HD_HCYL        0x1f5    /* high byte of starting cyl */
  20. #define HD_CURRENT    0x1f6    /* 101dhhhh , d=drive, hhhh=head */
  21. #define HD_STATUS    0x1f7    /* see status-bits */
  22. #define HD_FEATURE HD_ERROR    /* same io address, read=error, write=feature */
  23. #define HD_PRECOMP HD_FEATURE    /* obsolete use of this port - predates IDE */
  24. #define HD_COMMAND HD_STATUS    /* same io address, read=status, write=cmd */
  25.  
  26. #define HD_CMD        0x3f6    /* used for resets */
  27. #define HD_ALTSTATUS    0x3f6    /* same as HD_STATUS but doesn't clear irq */
  28.  
  29. /* remainder is shared between hd.c, ide.c, ide-cd.c, and the hdparm utility */
  30.  
  31. /* Bits of HD_STATUS */
  32. #define ERR_STAT    0x01
  33. #define INDEX_STAT    0x02
  34. #define ECC_STAT    0x04    /* Corrected error */
  35. #define DRQ_STAT    0x08
  36. #define SEEK_STAT    0x10
  37. #define WRERR_STAT    0x20
  38. #define READY_STAT    0x40
  39. #define BUSY_STAT    0x80
  40.  
  41. /* Values for HD_COMMAND */
  42. #define WIN_RESTORE        0x10
  43. #define WIN_READ        0x20
  44. #define WIN_WRITE        0x30
  45. #define WIN_WRITE_VERIFY    0x3C
  46. #define WIN_VERIFY        0x40
  47. #define WIN_FORMAT        0x50
  48. #define WIN_INIT        0x60
  49. #define WIN_SEEK        0x70
  50. #define WIN_DIAGNOSE        0x90
  51. #define WIN_SPECIFY        0x91    /* set drive geometry translation */
  52. #define WIN_SETIDLE1        0xE3
  53. #define WIN_SETIDLE2        0x97
  54.  
  55. #define WIN_STANDBYNOW1        0xE0
  56. #define WIN_STANDBYNOW2        0x94
  57. #define WIN_SLEEPNOW1        0xE6
  58. #define WIN_SLEEPNOW2        0x99
  59. #define WIN_CHECKPOWERMODE1    0xE5
  60. #define WIN_CHECKPOWERMODE2    0x98
  61.  
  62. #define WIN_DOORLOCK        0xde    /* lock door on removable drives */
  63. #define WIN_DOORUNLOCK        0xdf    /* unlock door on removable drives */
  64.  
  65. #define WIN_MULTREAD        0xC4    /* read sectors using multiple mode */
  66. #define WIN_MULTWRITE        0xC5    /* write sectors using multiple mode */
  67. #define WIN_SETMULT        0xC6    /* enable/disable multiple mode */
  68. #define WIN_IDENTIFY        0xEC    /* ask drive to identify itself    */
  69. #define WIN_IDENTIFY_DMA    0xEE    /* same as WIN_IDENTIFY, but DMA */
  70. #define WIN_SETFEATURES        0xEF    /* set special drive features */
  71. #define WIN_READDMA        0xc8    /* read sectors using DMA transfers */
  72. #define WIN_WRITEDMA        0xca    /* write sectors using DMA transfers */
  73.  
  74. #define WIN_READ_BUFFER        0xE4    /* force read only 1 sector */
  75. #define WIN_WRITE_BUFFER    0xE8    /* force write only 1 sector */
  76.  
  77. #define WIN_SMART        0xb0    /* self-monitoring and reporting */
  78.  
  79. /* Additional drive command codes used by ATAPI devices. */
  80. #define WIN_PIDENTIFY        0xA1    /* identify ATAPI device    */
  81. #define WIN_SRST        0x08    /* ATAPI soft reset command */
  82. #define WIN_PACKETCMD        0xa0    /* Send a packet command. */
  83.  
  84. /* WIN_SMART sub-commands */
  85.  
  86. #define SMART_READ_VALUES    0xd0
  87. #define SMART_READ_THRESHOLDS    0xd1
  88. #define SMART_AUTOSAVE        0xd2
  89. #define SMART_SAVE        0xd3
  90. #define SMART_IMMEDIATE_OFFLINE    0xd4
  91. #define SMART_ENABLE        0xd8
  92. #define SMART_DISABLE        0xd9
  93. #define SMART_STATUS        0xda
  94. #define SMART_AUTO_OFFLINE    0xdb
  95.  
  96. /* WIN_SECURITY sub-commands */
  97. #define SECURITY_SET_PASSWORD        0xBA    /* 0xF1 */
  98. #define SECURITY_UNLOCK            0xBB    /* 0xF2 */
  99. #define SECURITY_ERASE_PREPARE        0xBC    /* 0xF3 */
  100. #define SECURITY_ERASE_UNIT        0xBD    /* 0xF4 */
  101. #define SECURITY_FREEZE_LOCK        0xBE    /* 0xF5 */
  102. #define SECURITY_DISABLE_PASSWORD    0xBF    /* 0xF6 */
  103.  
  104. /* Bits for HD_ERROR */
  105. #define MARK_ERR    0x01    /* Bad address mark */
  106. #define TRK0_ERR    0x02    /* couldn't find track 0 */
  107. #define ABRT_ERR    0x04    /* Command aborted */
  108. #define MCR_ERR        0x08    /* media change request */
  109. #define ID_ERR        0x10    /* ID field not found */
  110. #define ECC_ERR        0x40    /* Uncorrectable ECC error */
  111. #define    BBD_ERR        0x80    /* pre-EIDE meaning:  block marked bad */
  112. #define    ICRC_ERR    0x80    /* new meaning:  CRC error during transfer */
  113.  
  114. struct hd_geometry {
  115.       unsigned char heads;
  116.       unsigned char sectors;
  117.       unsigned short cylinders;
  118.       unsigned long start;
  119. };
  120.  
  121. /* hd/ide ctl's that pass (arg) ptrs to user space are numbered 0x030n/0x031n */
  122. #define HDIO_GETGEO        0x0301    /* get device geometry */
  123. #define HDIO_GET_UNMASKINTR    0x0302    /* get current unmask setting */
  124. #define HDIO_GET_MULTCOUNT    0x0304    /* get current IDE blockmode setting */
  125. #define HDIO_OBSOLETE_IDENTITY    0x0307    /* OBSOLETE, DO NOT USE: returns 142 bytes */
  126. #define HDIO_GET_KEEPSETTINGS    0x0308    /* get keep-settings-on-reset flag */
  127. #define HDIO_GET_32BIT        0x0309    /* get current io_32bit setting */
  128. #define HDIO_GET_NOWERR        0x030a    /* get ignore-write-error flag */
  129. #define HDIO_GET_DMA        0x030b    /* get use-dma flag */
  130. #define HDIO_GET_NICE        0x030c    /* get nice flags */
  131. #define HDIO_GET_IDENTITY    0x030d    /* get IDE identification info */
  132. #define HDIO_DRIVE_CMD        0x031f    /* execute a special drive command */
  133.  
  134. /* hd/ide ctl's that pass (arg) non-ptr values are numbered 0x032n/0x033n */
  135. #define HDIO_SET_MULTCOUNT    0x0321    /* change IDE blockmode */
  136. #define HDIO_SET_UNMASKINTR    0x0322    /* permit other irqs during I/O */
  137. #define HDIO_SET_KEEPSETTINGS    0x0323    /* keep ioctl settings on reset */
  138. #define HDIO_SET_32BIT        0x0324    /* change io_32bit flags */
  139. #define HDIO_SET_NOWERR        0x0325    /* change ignore-write-error flag */
  140. #define HDIO_SET_DMA        0x0326    /* change use-dma flag */
  141. #define HDIO_SET_PIO_MODE    0x0327    /* reconfig interface to new speed */
  142. #define HDIO_SCAN_HWIF        0x0328    /* register and (re)scan interface */
  143. #define HDIO_SET_NICE        0x0329    /* set nice flags */
  144. #define HDIO_UNREGISTER_HWIF    0x032a  /* unregister interface */
  145.  
  146. /* structure returned by HDIO_GET_IDENTITY, as per ANSI ATA2 rev.2f spec */
  147. struct hd_driveid {
  148.     unsigned short    config;        /* lots of obsolete bit flags */
  149.     unsigned short    cyls;        /* "physical" cyls */
  150.     unsigned short    reserved2;    /* reserved (word 2) */
  151.     unsigned short    heads;        /* "physical" heads */
  152.     unsigned short    track_bytes;    /* unformatted bytes per track */
  153.     unsigned short    sector_bytes;    /* unformatted bytes per sector */
  154.     unsigned short    sectors;    /* "physical" sectors per track */
  155.     unsigned short    vendor0;    /* vendor unique */
  156.     unsigned short    vendor1;    /* vendor unique */
  157.     unsigned short    vendor2;    /* vendor unique */
  158.     unsigned char    serial_no[20];    /* 0 = not_specified */
  159.     unsigned short    buf_type;
  160.     unsigned short    buf_size;    /* 512 byte increments; 0 = not_specified */
  161.     unsigned short    ecc_bytes;    /* for r/w long cmds; 0 = not_specified */
  162.     unsigned char    fw_rev[8];    /* 0 = not_specified */
  163.     unsigned char    model[40];    /* 0 = not_specified */
  164.     unsigned char    max_multsect;    /* 0=not_implemented */
  165.     unsigned char    vendor3;    /* vendor unique */
  166.     unsigned short    dword_io;    /* 0=not_implemented; 1=implemented */
  167.     unsigned char    vendor4;    /* vendor unique */
  168.     unsigned char    capability;    /* bits 0:DMA 1:LBA 2:IORDYsw 3:IORDYsup*/
  169.     unsigned short    reserved50;    /* reserved (word 50) */
  170.     unsigned char    vendor5;    /* vendor unique */
  171.     unsigned char    tPIO;        /* 0=slow, 1=medium, 2=fast */
  172.     unsigned char    vendor6;    /* vendor unique */
  173.     unsigned char    tDMA;        /* 0=slow, 1=medium, 2=fast */
  174.     unsigned short    field_valid;    /* bits 0:cur_ok 1:eide_ok */
  175.     unsigned short    cur_cyls;    /* logical cylinders */
  176.     unsigned short    cur_heads;    /* logical heads */
  177.     unsigned short    cur_sectors;    /* logical sectors per track */
  178.     unsigned short    cur_capacity0;    /* logical total sectors on drive */
  179.     unsigned short    cur_capacity1;    /*  (2 words, misaligned int)     */
  180.     unsigned char    multsect;    /* current multiple sector count */
  181.     unsigned char    multsect_valid;    /* when (bit0==1) multsect is ok */
  182.     unsigned int    lba_capacity;    /* total number of sectors */
  183.     unsigned short    dma_1word;    /* single-word dma info */
  184.     unsigned short    dma_mword;    /* multiple-word dma info */
  185.     unsigned short  eide_pio_modes; /* bits 0:mode3 1:mode4 */
  186.     unsigned short  eide_dma_min;    /* min mword dma cycle time (ns) */
  187.     unsigned short  eide_dma_time;    /* recommended mword dma cycle time (ns) */
  188.     unsigned short  eide_pio;       /* min cycle time (ns), no IORDY  */
  189.     unsigned short  eide_pio_iordy; /* min cycle time (ns), with IORDY */
  190.     unsigned short  word69;
  191.     unsigned short  word70;
  192.     /* HDIO_GET_IDENTITY currently returns only words 0 through 70 */
  193.     unsigned short  word71;
  194.     unsigned short  word72;
  195.     unsigned short  word73;
  196.     unsigned short  word74;
  197.     unsigned short  word75;
  198.     unsigned short  word76;
  199.     unsigned short  word77;
  200.     unsigned short  word78;
  201.     unsigned short  word79;
  202.     unsigned short  word80;
  203.     unsigned short  word81;
  204.     unsigned short  command_sets;    /* bits 0:Smart 1:Security 2:Removable 3:PM */
  205.     unsigned short  word83;        /* bits 14:Smart Enabled 13:0 zero */
  206.     unsigned short  word84;
  207.     unsigned short  word85;
  208.     unsigned short  word86;
  209.     unsigned short  word87;
  210.     unsigned short  dma_ultra;
  211.     unsigned short    word89;        /* reserved (word 89) */
  212.     unsigned short    word90;        /* reserved (word 90) */
  213.     unsigned short    word91;        /* reserved (word 91) */
  214.     unsigned short    word92;        /* reserved (word 92) */
  215.     unsigned short    word93;        /* reserved (word 93) */
  216.     unsigned short    word94;        /* reserved (word 94) */
  217.     unsigned short    word95;        /* reserved (word 95) */
  218.     unsigned short    word96;        /* reserved (word 96) */
  219.     unsigned short    word97;        /* reserved (word 97) */
  220.     unsigned short    word98;        /* reserved (word 98) */
  221.     unsigned short    word99;        /* reserved (word 99) */
  222.     unsigned short    word100;    /* reserved (word 100) */
  223.     unsigned short    word101;    /* reserved (word 101) */
  224.     unsigned short    word102;    /* reserved (word 102) */
  225.     unsigned short    word103;    /* reserved (word 103) */
  226.     unsigned short    word104;    /* reserved (word 104) */
  227.     unsigned short    word105;    /* reserved (word 105) */
  228.     unsigned short    word106;    /* reserved (word 106) */
  229.     unsigned short    word107;    /* reserved (word 107) */
  230.     unsigned short    word108;    /* reserved (word 108) */
  231.     unsigned short    word109;    /* reserved (word 109) */
  232.     unsigned short    word110;    /* reserved (word 110) */
  233.     unsigned short    word111;    /* reserved (word 111) */
  234.     unsigned short    word112;    /* reserved (word 112) */
  235.     unsigned short    word113;    /* reserved (word 113) */
  236.     unsigned short    word114;    /* reserved (word 114) */
  237.     unsigned short    word115;    /* reserved (word 115) */
  238.     unsigned short    word116;    /* reserved (word 116) */
  239.     unsigned short    word117;    /* reserved (word 117) */
  240.     unsigned short    word118;    /* reserved (word 118) */
  241.     unsigned short    word119;    /* reserved (word 119) */
  242.     unsigned short    word120;    /* reserved (word 120) */
  243.     unsigned short    word121;    /* reserved (word 121) */
  244.     unsigned short    word122;    /* reserved (word 122) */
  245.     unsigned short    word123;    /* reserved (word 123) */
  246.     unsigned short    word124;    /* reserved (word 124) */
  247.     unsigned short    word125;    /* reserved (word 125) */
  248.     unsigned short    word126;    /* reserved (word 126) */
  249.     unsigned short    word127;    /* reserved (word 127) */
  250.     unsigned short    security;    /* bits 0:support 1:enabled 2:locked 3:frozen */
  251.     unsigned short    reserved[127];
  252. };
  253.  
  254. /*
  255.  * IDE "nice" flags. These are used on a per drive basis to determine
  256.  * when to be nice and give more bandwidth to the other devices which
  257.  * share the same IDE bus.
  258.  */
  259. #define IDE_NICE_DSC_OVERLAP    (0)    /* per the DSC overlap protocol */
  260. #define IDE_NICE_ATAPI_OVERLAP    (1)    /* not supported yet */
  261. #define IDE_NICE_0        (2)    /* when sure that it won't affect us */
  262. #define IDE_NICE_1        (3)    /* when probably won't affect us much */
  263. #define IDE_NICE_2        (4)    /* when we know it's on our expense */
  264.  
  265. #ifdef __KERNEL__
  266. /*
  267.  * These routines are used for kernel command line parameters from main.c:
  268.  */
  269. #include <linux/config.h>
  270.  
  271. #ifdef CONFIG_BLK_DEV_HD
  272. void hd_setup(char *, int *);
  273. #endif    /* CONFIG_BLK_DEV_HD */
  274.  
  275. #if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE)
  276. int ide_register(int io_port, int ctl_port, int irq);
  277. void ide_unregister(unsigned int);
  278. #endif /* CONFIG_BLK_DEV_IDE || CONFIG_BLK_DEV_IDE_MODULE */
  279.  
  280. #endif  /* __KERNEL__ */
  281.  
  282. #endif    /* _LINUX_HDREG_H */
  283.